var __ulogo = {
	'imgelem': function() {
		return document.getElementById('bind-jg-logo');
	},
	'process': function() {
		
	},
	'complete': function(res) {
		if(res.status == 201) {
			$('#ipt-jg-logo').val(res.data.uri);
		} else {
			$.toptip(res.error, 'error');
		}
	}
};

var __getdata_orgvolist = {},
	__getdata_orgadd = {};

factory.request('_org_volist');

$(function() {
	$('#btn-panduanjg').on('click', function(e) {
		var _val = $('#ipt-jgname').val();
		if (_val == '') {
			$.toptip('请选择投资机构', 'error');
		} else {
			checkLocation('pass');
		}
	});
	$('#mvolist').on('click', 'a', function(e) {
		var that = $(this),
			tlt = that.attr('data-title');
		$('#ipt-jgname').val(tlt);
		$('[data-itor=#ipt-jgname]').find('.value-text').html(tlt);
		checkLocation('mechanism');
	});
	$('#btn-addjg').on('click', function(e) {
		$.showLoading();
		__getdata_orgadd = {
			'logo': $('#ipt-jg-logo').val(),
			'title': $('#ipt-jg-title').val(),
			'introduction': $('#ipt-jg-info').val()
		};
		factory.request('_org_add');
	});
});

function __complete_orgvolist(res) {
	if(res.status == 200) {
		var ele = '';
		for(var i in res.data) {
			var list = res.data[i];
			ele += '<a class="weui-cell" href="javascript:;" data-title="' + list.title + '">';
			ele += '<div class="weui-cell__hd" style="position: relative;margin-right: 10px;">';
			ele += '<img src="' + list.logo + '" class="pro-logo" >';
			ele += '</div>';
			ele += '<div class="weui-cell__bd">';
			ele += '<p>' + list.title + '</p>';
			ele += '</div>';
			ele += '</a>';
		}
		$('#mvolist').html(ele);
	} else {
		$.toptip(res.error, 'error');
	}
}

function __complete_orgadd(res) {
	$.hideLoading();
	if(res.status == 201) {
		$('#ipt-jgname').val(__getdata_orgadd.title);
		$('[data-itor=#ipt-jgname]').find('.value-text').html(__getdata_orgadd.title);
		checkLocation('mechanism');
	} else {
		$.toptip(res.error, 'error');
	}
}